package {
	import com.bumpslide.tween.FTween;	
	import com.bumpslide.ui.Applet;
	import com.bumpslide.ui.Image;
	import com.bumpslide.ui.ScrollPanel;
	import com.bumpslide.ui.constants.Direction;
	import com.bumpslide.util.Align;
	
	import flash.display.BlendMode;		

	/**
	 * Panel Demo for Andy Hatch with scrollbar on left
	 * 
	 * @mxmlc -sp+=../../classes -debug
	 * @author David Knape
	 */
	[SWF(frameRate=31, backgroundColor="#cceedd")]
	public class ScrollbarOnLeft extends Applet {

		private var scrollpanel:ScrollPanel;

		override protected function addChildren():void {
			
			// create scrollpanel with image as content
			scrollpanel = new LeftHandScroll();
			scrollpanel.visible = false;
			scrollpanel.setSize( 300, 300);
			scrollpanel.content = new Image( 'http://farm4.static.flickr.com/3056/2904309541_4091bbef57.jpg' );
			(scrollpanel.content as Image).fadeOnLoad = true;
			addChild( scrollpanel );
			FTween.fadeIn( scrollpanel, 500 );
			
			// pretty it up
			scrollpanel.background.blendMode = BlendMode.MULTIPLY;			scrollpanel.scrollbar.blendMode = BlendMode.MULTIPLY;
			scrollpanel.scrollbar.alpha = .6;
			
			// horizontal works, too...
			if(loaderInfo.parameters.h) scrollpanel.orientation = Direction.HORIZONTAL;
			
			// when image is loaded, update scrollpanel
			addEventListener( Image.EVENT_LOADED, eventDelegate( scrollpanel.updateNow ) );		
		}

		override protected function draw():void {
			scrollpanel.setSize( 300, Math.round( height - 100));
			scrollpanel.y = 50;
			Align.center( scrollpanel, width );			
		}
	}
}

import com.bumpslide.ui.Panel;
import com.bumpslide.ui.ScrollPanel;

/**
 * Left Hand  Scroll Panel
 * 
 * If horizontal, scrollbar will be on top.
 *  
 */
class LeftHandScroll extends ScrollPanel {
		
	override protected function positionContent():void {
		_holder.x = padding.left;
		_holder.y = padding.top;
		
		if(scrollbar.visible) {
			if(isVertical) {
				_holder.x += scrollbarWidth + gap;
			} else {
				_holder.y += scrollbarWidth + gap;
			}	
		}
	}

	override protected function positionScrollbar():void {
		scrollbar.move( padding.left, padding.top);
	}
}
